/**
 * @brief Calcualtor Version 2, Using encapsulation feature of OOP.
 * The first version of calculator business logic and interface logic are coupled together, 
 * which is not conducive to code maintenance
 * @author fujie
 * @date 2021-06-27 14:15:21
*/

#include <stdio.h>

class Operation
{
private:
    int adderA, adderB;
    char symbol;

public:
    Operation(/* args */);
    Operation(int a,int b,char s);
    ~Operation();
    int getResult();
};
int Operation::getResult()
{
    if (symbol == '+')
        return adderA + adderB;
    else if (symbol == '-')
        return adderA - adderB;

    return 0; // default return value is 0
}

Operation::Operation(int a,int b,char s)
{
    adderA=a;
    adderB=b;
    symbol=s;
}
Operation::Operation(/* args */)
{
    printf("Constructor\n");
    adderA = 0;
    adderB = 0;
    symbol = '+';
}

Operation::~Operation()
{
    printf("Destructor\n");
}


int main()
{
    int adderA = 0, adderB = 0, result = 0;
    char symbol;
    printf("input adder A: ");
    scanf("%d", &adderA);
    printf("input adder B: ");
    scanf("%d", &adderB);

    printf("input symbol: ");
    getchar(); // get the \n before get char symbol
    symbol = getchar(); // input a char variable

    Operation oper(adderA,adderB,symbol);
    printf("result = %d\n",oper.getResult());
}